package net.midnighttd.game.sprite;

import net.midnighttd.engine.view.sprite.Sprite;

import java.awt.*;

/**
 * Author: Adam Scarr
 * Date: 24/04/2009
 * Time: 8:55:45 PM
 */
public class HPBar extends Sprite {
    private double fullness = 1;

    public HPBar(Sprite copy) {
        super(copy);
    }

    public HPBar(int width) {
        super("HPBAR", width, 5, 100);
    }

    public void setFullness(double fullness) {
        this.fullness = fullness;
    }

    public void draw(Graphics g) {
        g.setColor(new Color(150, 147, 142));
        g.fillRect(getX(), getY(), getWidth(), getHeight());

        int fullSize = (int)(fullness * getWidth());

        g.setColor(new Color(200, 70, 70));
        g.fillRect(getX(), getY(), fullSize, getHeight());

        g.setColor(new Color(38, 35, 30));
        g.drawRect(getX(), getY(), getWidth(), getHeight());
    }

    public Sprite copy() {
        return new HPBar(this);
    }
}
